import { ApiProperty } from '@nestjs/swagger'
import { IsString, IsEmail, IsOptional, MinLength, MaxLength } from 'class-validator'

/**
 * 创建用户DTO
 * 用于用户注册和创建
 */
export class CreateUserDto {
  @ApiProperty({ description: '用户名', example: 'admin' })
  @IsString()
  @MinLength(3)
  @MaxLength(20)
  username: string

  @ApiProperty({ description: '邮箱', example: 'admin@example.com' })
  @IsEmail()
  email: string

  @ApiProperty({ description: '密码', example: '123456' })
  @IsString()
  @MinLength(6)
  password: string

  @ApiProperty({ description: '昵称', example: '管理员', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(50)
  nickname?: string

  @ApiProperty({ description: '手机号', example: '13800138000', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(20)
  phone?: string

  @ApiProperty({ description: '头像', example: 'https://example.com/avatar.jpg', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  avatar?: string
}
